Skip to content

fix(solid-form): fix props reactivity in withForm and withFieldGroupInitialized Repository#2058

Merged
crutchcorn merged 3 commits intoTanStack:mainfrom
balhyo-younjisang:fix/with-form-props-reactivity
Mar 4, 2026
Merged

fix(solid-form): fix props reactivity in withForm and withFieldGroupInitialized Repository#2058
crutchcorn merged 3 commits intoTanStack:mainfrom
balhyo-younjisang:fix/with-form-props-reactivity

Conversation

@balhyo-younjisang
Copy link
Contributor

🎯 Changes

Fix props passed to withForm and withFieldGroup components not being reactive. (closes #2054)

withForm and withFieldGroup used object spread ({ ...props, ...innerProps })
to pass props to the render function.

In SolidJS, JSX props are passed as getter functions internally.
Object spread eagerly evaluates those getters and copies only the resulting values,
which breaks signal tracking.

// Parent component
<InstituteForm status={status()} />

// SolidJS compiles this to
createComponent(InstituteForm, {
  get status() { return status() }  // reactive getter
})

// But spread evaluates the getter immediately, producing a static value
{ ...innerProps }    { status: 'idle' }  // reactivity lost

As a result, even when the parent updates a signal, createEffect inside render
never re-runs and the JSX never updates.

Replace object spread with mergeProps() to preserve the reactive getters,
and call render via createComponent() to maintain the correct SolidJS
reactive context.

  // Before
  return (innerProps) => render({ ...props, ...innerProps })

  // After
  return (innerProps) => createComponent(
    render as Component<any>,
    mergeProps(props ?? {}, innerProps)
  )

The same fix is applied to withFieldGroup.

Add regression tests to verify JSX reactivity and createEffect re-runs
when signal props change in withForm and withFieldGroup.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

   - Replace object spread with mergeProps() to preserve reactive getters
   - Call render via createComponent() to maintain SolidJS reactive context
   - Add regression tests for withForm and withFieldGroup reactivity
   - Replace object spread with mergeProps() to preserve reactive getters
   - Call render via createComponent() to maintain SolidJS reactive context
   - Add regression tests for withForm and withFieldGroup reactivity

   Fixes TanStack#2054
@changeset-bot
Copy link

changeset-bot bot commented Mar 3, 2026

🦋 Changeset detected

Latest commit: 1b15b84

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@tanstack/solid-form Patch
@tanstack/form-core Patch
@tanstack/react-form Patch
@tanstack/react-form-start Patch
@tanstack/react-form-remix Patch
@tanstack/react-form-nextjs Patch
@tanstack/angular-form Patch
@tanstack/vue-form Patch
@tanstack/svelte-form Patch
@tanstack/form-devtools Patch
@tanstack/lit-form Patch
@tanstack/react-form-devtools Patch
@tanstack/solid-form-devtools Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@nx-cloud
Copy link

nx-cloud bot commented Mar 4, 2026

View your CI Pipeline Execution ↗ for commit 1b15b84

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 1m View ↗
nx run-many --target=build --exclude=examples/** ✅ Succeeded 8s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-04 12:49:27 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 4, 2026

More templates

@tanstack/angular-form

npm i https://pkg.pr.new/@tanstack/angular-form@2058

@tanstack/form-core

npm i https://pkg.pr.new/@tanstack/form-core@2058

@tanstack/form-devtools

npm i https://pkg.pr.new/@tanstack/form-devtools@2058

@tanstack/lit-form

npm i https://pkg.pr.new/@tanstack/lit-form@2058

@tanstack/react-form

npm i https://pkg.pr.new/@tanstack/react-form@2058

@tanstack/react-form-devtools

npm i https://pkg.pr.new/@tanstack/react-form-devtools@2058

@tanstack/react-form-nextjs

npm i https://pkg.pr.new/@tanstack/react-form-nextjs@2058

@tanstack/react-form-remix

npm i https://pkg.pr.new/@tanstack/react-form-remix@2058

@tanstack/react-form-start

npm i https://pkg.pr.new/@tanstack/react-form-start@2058

@tanstack/solid-form

npm i https://pkg.pr.new/@tanstack/solid-form@2058

@tanstack/solid-form-devtools

npm i https://pkg.pr.new/@tanstack/solid-form-devtools@2058

@tanstack/svelte-form

npm i https://pkg.pr.new/@tanstack/svelte-form@2058

@tanstack/vue-form

npm i https://pkg.pr.new/@tanstack/vue-form@2058

commit: 0de4225

Copy link
Member

@crutchcorn crutchcorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me! Thanks for this! Let me run some CI/CD checks and we'll merge after

@crutchcorn crutchcorn merged commit cb2ad34 into TanStack:main Mar 4, 2026
4 checks passed
@github-actions github-actions bot mentioned this pull request Mar 4, 2026
@sentry
Copy link

sentry bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.49%. Comparing base (6892ed0) to head (1b15b84).
⚠️ Report is 142 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2058      +/-   ##
==========================================
+ Coverage   90.35%   95.49%   +5.14%     
==========================================
  Files          38        4      -34     
  Lines        1752      111    -1641     
  Branches      444        9     -435     
==========================================
- Hits         1583      106    -1477     
+ Misses        149        5     -144     
+ Partials       20        0      -20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Props passed to the components generated by withForm are not reactive

2 participants